/**
 * @description  访问统计
 * @author shenhong
 */
import React, { PureComponent } from 'react';
import { connect } from 'dva';
import { SunEchartsC, SecondHeaderC } from '../../../comps';
import style from './index.less';

class showEchartsThree extends PureComponent {
  constructor() {
    super();
    this.state = {};
  }
  componentDidMount() {
    const { dispatch, args } = this.props;
    dispatch({
      type: 'visitStatisticsM/getEchartsThree',
      payload: args,
    });
  }
  UNSAFE_componentWillReceiveProps(nextProps) {
    const { args, timeStamp } = nextProps;
    if (JSON.stringify(args) !== JSON.stringify(this.props.args) || timeStamp !== this.props.timeStamp) {
      const { dispatch } = this.props;
      dispatch({
        type: 'visitStatisticsM/save',
        payload: { getEchartsThree: { list: undefined }, size: null },
      });
      dispatch({
        type: 'visitStatisticsM/getEchartsThree',
        payload: args,
      });
    }
  }

  render() {
    const {
      visitStatisticsM: { getEchartsThree },
    } = this.props;
    const data = getEchartsThree.list;
    const account = getEchartsThree.size;
    return (
      <div className={style.body_area}>
        <SecondHeaderC title='功能分布' />
        <div className='showEcharts2'>
          <SunEchartsC data={data} height='460px' total={account} />
        </div>
      </div>
    );
  }
}
export default connect(({ visitStatisticsM }) => ({
  visitStatisticsM,
}))(showEchartsThree);
